package org.glut.wechat.addresslist.common;

import lombok.Data;

/**
 * @author Harry
 * @create time 2025/8/20 21:51
 */
@Data
public class Result<T> {
    private int code;       // 200成功，500失败
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> res = new Result<>();
        res.code = 200;
        res.msg = "success";
        res.data = data;
        return res;
    }
    // 支持返回数据 + 消息
    public static <T> Result<T> ok(T data) {
        Result<T> res = new Result<>();
        res.code = 200;
        res.msg = "成功";
        res.data = data;
        return res;
    }

    // 支持仅返回消息（无数据）
    public static <T> Result<T> ok(String msg) {
        Result<T> res = new Result<>();
        res.code = 200;
        res.msg = msg;
        return res;
    }
    public static <T> Result<T> fail(String msg) {
        Result<T> res = new Result<>();
        res.code = 500;
        res.msg = msg;
        return res;
    }

}